﻿@{
    var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
    var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;

    //page title
    ViewBag.Title = T("Admin.Customers.OnlineCustomers").Text;
}
<div class="section-header">
    <div class="title">
        <img src="@Url.Content("~/Administration/Content/images/ico-customers.png")" alt="" />
        @T("Admin.Customers.OnlineCustomers")
    </div>
    <div class="options">
    </div>
</div>
<table class="adminContent">
    <tr>
        <td>
            <div id="onlinecustomers-grid"></div>

            <script>
                $(document).ready(function () {
                    $("#onlinecustomers-grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            transport: {
                                read: {
                                    url: "@Html.Raw(Url.Action("List", "OnlineCustomer"))",
                                    type: "POST",
                                    dataType: "json"
                                }
                            },
                            schema: {
                                data: "Data",
                                total: "Total",
                                errors: "Errors"
                            },
                            error: function(e) {
                                display_kendoui_grid_error(e);
                                // Cancel the changes
                                this.cancelChanges();
                            },
                            pageSize: @(defaultGridPageSize),
                            serverPaging: true,
                            serverFiltering: true,
                            serverSorting: true
                        },
                        pageable: {
                            refresh: true,
                            pageSizes: [@(gridPageSizes)]
                        },
                        editable: {
                            confirmation: false,
                            mode: "inline"
                        },
                        scrollable: false,
                        columns: [{
                            field: "Id",
                            title: "@T("Admin.Customers.OnlineCustomers.Fields.CustomerInfo")",
                            template: '<a href="@Url.Content("~/Admin/Customer/Edit/")#=Id#">#:CustomerInfo#</a>'
                        }, {
                            field: "LastIpAddress",
                            title: "@T("Admin.Customers.OnlineCustomers.Fields.IPAddress")"
                        }, {
                            field: "Location",
                            title: "@T("Admin.Customers.OnlineCustomers.Fields.Location")"
                        }, {
                            field: "LastActivityDate",
                            title: "@T("Admin.Customers.OnlineCustomers.Fields.LastActivityDate")",
                            width: 200,
                            type: "date",
                            format: "{0:G}"
                        }, {
                            field: "LastVisitedPage",
                            title: "@T("Admin.Customers.OnlineCustomers.Fields.LastVisitedPage")"
                        }]
                    });
                });
            </script>
        </td>
    </tr>
</table>
